#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
Author: Faker.Deng
Exercise after Chapter 1 Problem 6
"""


# Problem 6
def payroll_report():
    """
    Read a text file and display a table
    :return: None
    """
    file_name = input("Please input payroll file: ")
    file = open(file_name, 'r')
    print("+--------------------------------------+")
    print("|           Payroll Report             |")
    print("+------------+--------------+----------+")
    print("|    Name    | Hours worked |  Salary  |")
    print("+------------+--------------+----------+")
    for line in file:
        word_list = line.split()
        name = word_list[0]
        hours_worked = float(word_list[2])
        salary = hours_worked * float(word_list[1])
        print("|" + name.center(12) + "|" + ("% .1f" % hours_worked).center(14) + "|" + "%10.2f" % salary + "|")
    print("+------------+--------------+----------+")
    return


if __name__ == "__main__":
    payroll_report()
